<template>
    <div>
          <h2>{{cityname}}--城市界面</h2>
          <div id="main" style="width:7.5rem;height:9rem"></div>
    </div>
</template>

<script>
import api from "../../api/index";
export default {
    props:['cityname'],
    mounted(){
        // this.$myChart.cityMap('main', this.cityname, [])
        api.getCity(this.cityname)
        .then((res)=>{
            let arr = res.data.retdata.subList;
            let newArr = [];
            arr.forEach((ele)=>{
                let obj={}
                //名称处理
                if ( ele.city.endsWith("区") ||ele.city.endsWith("州") ||ele.city.endsWith("盟")||ele.city.endsWith("旗")) {
                    obj.name = ele.city;
                } else {
                    obj.name = ele.city + "市";
                }
                obj.value = ele.confirm;
                newArr.push(obj)
            });
            this.$myChart.cityMap('main', this.cityname, newArr)
        })
    }
}
</script>

<style>

</style>